define(['../../carrys/cityList','../../carrys/jsonList','../../../../js/lib/other/sweet-alert'],function(cityData,jsonList) {
    return ['$scope','$location', '$interval','$timeout','bizProxy', function($scope,$location,$interval,$timeout,bizProxy) {
    	$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','loan'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','62'); 	//显示底部文字
    	
    	//点击提交内容
    	$scope.goNext = function(){
    		subApplyData();
    	}
    	
    	//提交申请资料
        function subApplyData(){
        	var headerInfo = {},bizInfo = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;

        	bizInfo.inviteCode = resultData.loginUserData.inviteCode;
    		bizInfo.lawyerNo = NPLCacheData.firstStepData.lawyerNo;
    		bizInfo.applyUserName = NPLCacheData.firstStepData.applyUserName;
    		bizInfo.lawyerCompName = NPLCacheData.firstStepData.lawyerCompName;
    		bizInfo.mobileNo = NPLCacheData.firstStepData.mobileNo;
    		bizInfo.npaName = NPLCacheData.secondStepData.propertyName;
    		bizInfo.npaOwner = NPLCacheData.secondStepData.sellerName;
    		bizInfo.npaPrice = _SYT_util.formatMoney(String(NPLCacheData.secondStepData.propertyPrice)*10000,2 )*1;
    		bizInfo.npaCaseAmount =  _SYT_util.formatMoney(String(NPLCacheData.secondStepData.UnderlyingPrice)*10000,2 )*1;
    		var tempnplAreaList = NPLCacheData.thirdStepData.nplAreaList;
    		var mortgageList = new Array();
    		for(var i=0;i<tempnplAreaList.length;i++){
    			var json = {
						"mortgageContent":tempnplAreaList[i].mortgagecase,
						"mortgageType":tempnplAreaList[i].mortgageType,
						"province":tempnplAreaList[i].province.province,
						"city":tempnplAreaList[i].city.city,
						"county":tempnplAreaList[i].county.district,
						"address":tempnplAreaList[i].address,
						"mortgageAmount":_SYT_util.formatMoney(String(tempnplAreaList[i].mortgageAmount)*10000,2 )*1
    			};
    			mortgageList.push(json);
    		}
    		bizInfo.mortgageList = mortgageList;
    		bizInfo.creditorName = NPLCacheData.thirdStepData.creditor;
    		bizInfo.cooperateMode = NPLCacheData.thirdStepData.collaborateType;
    		bizInfo.uploadEmail = "npa@winhc.cn";
    		$scope.$emit("loadingChange",true);
    		bizProxy.queryProxyBizData("npaApply",headerInfo,bizInfo,
    				function(tempData){//SUCCESS
    					$scope.$emit("loadingChange",false);
						$timeout(function(){
							FIREFLY("提交成功,请等待平台审核", "我方会在2个工作日内审核完毕","",function(){
								$timeout(function(){
									$scope.$emit("goNext","/");
								},0);
							});
						},100);
		    		},function(data){
		    			if(data != ""){//FAIL
		    				$scope.$emit("loadingChange",false);
							if(data.errorCode == ERROR_CODE.noLogin){
								FIREFLY("", data.errorMsg,"",function(){
										//调用退出登录
										transData.mobileNo = "";
		    							transData.password = "";
		    							transData.sessionId = "";
		    							transData.userType = "";
		    							resultData.loginUserData = "";
		    							resultData.loginResultData = "";
		    							$timeout(function(){
		    								$scope.$emit("goNext","/mine");
		    							},0);
								});
							}else{
								$scope.$emit("promptAlertMsg",data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
								},transData.promptTime);
							}
		    			}else{
		    				$scope.$emit("loadingChange",false);
							$scope.$emit("promptAlertMsg","连接超时");
							$scope.$emit("showCollect",true);
							$timeout(function(){
								$scope.$emit("showCollect",false);
							},transData.promptTime);
		    			}
		    		});
        }
    	$scope.$apply();
    }];
});